<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  

  
  <title>Huafeihua</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  
  
  <meta property="og:type" content="website">
<meta property="og:title" content="Huafeihua">
<meta property="og:url" content="http://malone00.gitee.io/huafeihua/page/2/index.html">
<meta property="og:site_name" content="Huafeihua">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Huafeihua">
  
    <link rel="alternate" href="/huafeihua/atom.xml" title="Huafeihua" type="application/atom+xml">
  
  
    <link rel="icon" href="/images/tmp.jpg">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/huafeihua/css/style.css">
  <link rel="stylesheet" href="/huafeihua/css/highlight.css">
</head>
</html>
<body>
  <div id="fullpage" class="mobile-nav-right">
    
      <div id="wrapper" title="图片来自网络">
    
    
      <header id="header">
  <div id="nav-toggle" class="nav-toggle"></div>
  <div class="head-box global-width">
    <nav class="nav-box nav-right">
      
        <a class="nav-item" href="/huafeihua/" title="">首页</a>
      
        <a class="nav-item" href="/huafeihua/categories" title="">分类</a>
      
        <a class="nav-item" href="/huafeihua/archives" title="">归档</a>
      
        <a class="nav-item" href="/huafeihua/tags" title="">标签</a>
      
        <a class="nav-item" href="/huafeihua/about" title="">关于</a>
      
    </nav>
  </div>
</header>
      <div id="middlecontent" title class="global-width sidebar-left">
        <section id="main">
  
    <article id="post-运维部署/Jenkins使用" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/运维部署/Jenkins使用/">Jenkins使用</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/运维部署/Jenkins使用/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/Jenkins/">Jenkins</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>#修改密码<br><img src="https://upload-images.jianshu.io/upload_images/4805565-1813f700dea5a7a0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="初始化密码"></p>
<p>粘贴密码，点击【继续】<br>更具需要选择插件，安装</p>
<p>#创建管理员账号<br><img src="https://upload-images.jianshu.io/upload_images/4805565-2bf905df7e139b23.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>设置好，登陆后的界面：<br><img src="https://upload-images.jianshu.io/upload_images/4805565-4500819d0a836104.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>#新建项目<br><img src="https://upload-images.jianshu.io/upload_images/4805565-2e281b9ac6cb1666.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>下拉到最下面<br>选择执行shell<br><img src="https://upload-images.jianshu.io/upload_images/4805565-14dc27b8f1516c36.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>mathtest.py</p>
<p><img src="https://upload-images.jianshu.io/upload_images/4805565-a8b5b8480e046946.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>立即构建<br><img src="https://upload-images.jianshu.io/upload_images/4805565-fb50afbd70ab6178.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>对于成功显示构建成功，单元测试失败，构建失败！</p>
<p><img src="https://upload-images.jianshu.io/upload_images/4805565-335dc5bc9100572e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="失败构建"></p>
<p>成功的图：<br><img src="https://upload-images.jianshu.io/upload_images/4805565-ca1f7fc9a7e9523a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="构建成功"></p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-运维部署/Docker-小白入门基于Windows-[下载镜像]" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/运维部署/Docker-小白入门基于Windows-[下载镜像]/">Docker下载镜像基于Win</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/运维部署/Docker-小白入门基于Windows-[下载镜像]/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/Docker/">Docker</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>1.下载一个Linux系统<br>在学习flask 下载一个书中提供的镜像</p>
<blockquote>
<p>docker pull dongweiming/web_develop:dev</p>
</blockquote>
<p><img src="https://upload-images.jianshu.io/upload_images/4805565-7e99942b7389bc4e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="下载镜像.png"></p>
<p>查看镜像</p>
<blockquote>
<p>docker images<br><img src="https://upload-images.jianshu.io/upload_images/4805565-eb178e24740c242d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="查看镜像.png"></p>
</blockquote>
<blockquote>
<p>docker run –name web_dev -it -p 9000:9000 -p 3141:3141 -p 5000:5000 dongweiming/web_dev  /bin/zsh</p>
</blockquote>
<p><em>–name 制定容器名字
</em>-p 暴露特定端口</p>
<ul>
<li>/bin/zsh  登录容器 默认shell</li>
<li>退出之后 启动容器 &gt;docker start web_dev<blockquote>
<p>docker attach web_dev      #回车2次</p>
</blockquote>
####端口转发<blockquote>
<p>docker-machine inspect|grep MachineName<br>“MachineName”:”default”,</p>
</blockquote>
</li>
</ul>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-运维部署/Docker-小白入门基于Windows-[环境安装]" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/运维部署/Docker-小白入门基于Windows-[环境安装]/">Docker安装基于Win</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/运维部署/Docker-小白入门基于Windows-[环境安装]/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/Docker/">Docker</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>1.安装Docker 环境<br>Docker 是一个基于Linux（LXC）环境的容器引擎，由Go语言开发</p>
<p>占用资源少，性能强劲，开销小<br>可移植性高，官网说明“一次封装，到处运行”，提高开发和运维的工作效率<br><a href="http://get.daocloud.io/" target="_blank" rel="noopener">http://get.daocloud.io/</a><br>到官网下载window安装包，docker基于Linux，所以win下就是用virtualbox 集成一个linux环境来运行docker<br>下载好，点击exe ，下一步下一步  win 你懂的。<br>完成后是这个样子：下图<br><img src="https://upload-images.jianshu.io/upload_images/4805565-a89cc09d57e17bb3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="安装完成.png"><br>启动虚拟机是下面这个样子：下图</p>
<p>输入<code>docker --help</code>显示正常docker环境就好了，可以玩耍了。<br><img src="https://upload-images.jianshu.io/upload_images/4805565-fd1b8dda5c7fcd1e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="检查环境.png"></p>
<p><code>docker version</code> 查看版本,其他命令自行熟悉。<br><img src="https://upload-images.jianshu.io/upload_images/4805565-651440e1c802e359.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="查看版本.png"><br>—–END—-</p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-运维部署/Centos7-安装Jenkins-小白解析" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/运维部署/Centos7-安装Jenkins-小白解析/">centos7安装jenkins</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/运维部署/Centos7-安装Jenkins-小白解析/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/Linux/">Linux</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/centos/">centos</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <blockquote>
<p>本例在VM虚拟机中实现</p>
</blockquote>
<p>#下载文件<br><a href="ttps://jenkins.io/download" target="_blank" rel="noopener">权威地址 </a><br><img src="https://upload-images.jianshu.io/upload_images/4805565-030174a4598f2806.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="选择版本"></p>
<p>#安装<br>命令行安装失败，下载rpm文件安装<br><img src="https://upload-images.jianshu.io/upload_images/4805565-168a9994554b1be2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="下载文件"><br>在下载路径执行命令<br>rpm -ivh jenkins-2.141-1.1.noarch.rpm<br>安装成功，提示100%</p>
<p>#启动服务<br>service jenkins start<br>看到【OK】<br>启动成功，在服务器本机访问OK<br><a href="http://localhost:8080" target="_blank" rel="noopener">http://localhost:8080</a>  可以访问<br>ifconfig 查看IP<br>物理机访问不通，查看防火墙<br>centos7 以上 不用service stop iptables<br>根据提示：<br>systemctl  stop firewalld<br>再次访问成功！如下图：<br><img src="https://upload-images.jianshu.io/upload_images/4805565-c60c51855fd0c25d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="初次访问界面"></p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/控制移动程序片段" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/控制移动程序片段/">Python-控制移动程序片段</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/控制移动程序片段/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>控制移动，原点 0.0<br>通过坐标移动<br>getp 查看位置<br>一个简单的实现如下</p>
<pre><code>a=[0,0]

def up():
    a[1] += 1

def down():
    a[1] -= 1

def left():
    a[0] -= 1

def rigth():
    a[0] += 1

while True:
    p = input(&apos;input fangxiang(up,down,left,right,getp, other to quit):&apos;)
    if p == &apos;up&apos;:
        up()
    elif p == &apos;down&apos;:
        down()
    elif p == &apos;left&apos;:
        left()
    elif p == &apos;right&apos;:
        rigth()
    elif p == &apos;getp&apos;:
        print(a)
    else:
        print(&apos;Stop move!&apos;)
        break  
</code></pre>
      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/配置文件-ini" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/配置文件-ini/">Python-ini配置文件</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/配置文件-ini/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>win 常用配置文件 ini<br>“.INI ”就是英文 “initialization”的头三个字母的缩写；当然INI file的后缀名也不一定是”.ini”也可以是”.cfg”，”.conf ”或者是”.txt”</p>
<p>[] 节<br>key=value</p>
<p>[default]  不处理<br>； 为注释</p>
<p>举例config.ini：<br>[DEFAULT]<br>path=’D:\config.ini’<br>author=Edwin</p>
<p>[DATABASE]<br>；mysql database info<br>IP =  10.1.0.1<br>PORT = 3306<br>USER = user<br>PWD = pwd</p>
<p>[EMAIL]<br>user=user<br>pwd = pwd</p>
<p>[HTTP]<br>IP = 10.10.10.10<br>addr = localhost:8080/response</p>
<hr>
<p>###python 读取<br>python 使用ConfigParser  python3 使用configparser<br>一个读取配置文件的类如下：<br><div class="highlight-box" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true" data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"># conding:utf-8</span><br><span class="line">import configparser</span><br><span class="line"></span><br><span class="line">class  ReadConfig():</span><br><span class="line"></span><br><span class="line">    def __init__(self):</span><br><span class="line">        #fd = open(&quot;config.ini&quot;, encoding=&quot;utf-8&quot;)</span><br><span class="line"></span><br><span class="line">        self.cf = configparser.ConfigParser()</span><br><span class="line">        self.cf.read(&quot;config.ini&quot;, encoding=&quot;utf-8&quot;)</span><br><span class="line"></span><br><span class="line">    def get_email(self, name):</span><br><span class="line">        value = self.cf.get(&quot;EMAIL&quot;, name)</span><br><span class="line">        return value</span><br><span class="line"></span><br><span class="line">    def get_http(self, name):</span><br><span class="line">        value = self.cf.get(&quot;HTTP&quot;, name)</span><br><span class="line">        return value</span><br><span class="line"></span><br><span class="line">    def get_db(self, name):</span><br><span class="line">        value = self.cf.get(&quot;DATABASE&quot;, name)</span><br><span class="line">        return value</span><br></pre></td></tr></table></figure></div></p>
<p>###使用<br><div class="highlight-box" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true" data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&gt;&gt;&gt; import ReadConfig</span><br><span class="line">&gt;&gt;&gt; cf = ReadConfig()</span><br><span class="line">&gt;&gt;&gt; cf.get_http(&apos;IP&apos;)</span><br><span class="line">&gt;&gt;&gt;&apos;10.10.10.10&apos;</span><br><span class="line">cf.get_db(&apos;PORT&apos;)</span><br><span class="line">&gt;&gt;&gt;&apos;3306&apos;</span><br></pre></td></tr></table></figure></div></p>
<p>还有其他方法，如set 修改value write 写入键值</p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/字符串转换" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/字符串转换/">Python-字符转换</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/字符串转换/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p> b = b”sa”    # bytes<br> s = “sa”  </p>
<h1 id="str-to-bytes"><a href="#str-to-bytes" class="headerlink" title="str to bytes"></a>str to bytes</h1><p> bytes(s, encoding = “utf8”)  </p>
<h1 id="bytes-to-str"><a href="#bytes-to-str" class="headerlink" title="bytes to str"></a>bytes to str</h1><p> str(b, encoding = “utf-8”)  </p>
<h1 id="another"><a href="#another" class="headerlink" title="another"></a>another</h1><h1 id="str-to-bytes-1"><a href="#str-to-bytes-1" class="headerlink" title="str to bytes"></a>str to bytes</h1><p> str.encode(s)  </p>
<h1 id="bytes-to-str-1"><a href="#bytes-to-str-1" class="headerlink" title="bytes to str"></a>bytes to str</h1><p> bytes.decode(b)  </p>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/图片下载" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/图片下载/">Python-图片下载</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/图片下载/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        

<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片下载</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">图片下载</h1>
        <div class="show-content">
          <blockquote>
<p>importurllib<br></p>
<p>url = r"http://www.iteye.com/images/logo.gif"</p>
<p>path = r"h:\downloads\1.jpg"</p>
<p>data = urllib.urlopen(url).read()</p>
<p>f = file(path,"wb")</p>
<p>f.write(data)</p>
<p>f.close()</p>
</blockquote>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/唯一值uuid" class="article global-container article-type-post" itemscope="" itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/唯一值uuid/">Python-唯一值Uuid</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/唯一值uuid/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        <p>UUID是128位的全局唯一标识符，通常由32字节的字符串表示。<br>GUID<br>它通过MAC地址、时间戳、命名空间、随机数、伪随机数来保证生成ID的唯一性。<br>    UUID主要有五个算法，也就是五种方法来实现：</p>
<pre><code> 1、uuid1()——基于时间戳

         由MAC地址、当前时间戳、随机数生成。可以保证全球范围内的唯一性，
         但MAC的使用同时带来安全性问题，局域网中可以使用IP来代替MAC。

 2、uuid2()——基于分布式计算环境DCE（Python中没有这个函数）

          算法与uuid1相同，不同的是把时间戳的前4位置换为POSIX的UID。
          实际中很少用到该方法。

3、uuid3()——基于名字的MD5散列值

          通过计算名字和命名空间的MD5散列值得到，保证了同一命名空间中不同名字的唯一性，
          和不同命名空间的唯一性，但同一命名空间的同一名字生成相同的uuid。    

 4、uuid4()——基于随机数

          由伪随机数得到，有一定的重复概率，该概率可以计算出来。

 5、uuid5()——基于名字的SHA-1散列值

          算法与uuid3相同，不同的是使用 Secure Hash Algorithm 1 算法
</code></pre><p>使用方面：</p>
<pre><code>首先，Python中没有基于DCE的，所以uuid2可以忽略；
其次，uuid4存在概率性重复，由无映射性，最好不用；
再次，若在Global的分布式计算环境下，最好用uuid1；
最后，若有名字的唯一性要求，最好用uuid3或uuid5。
</code></pre><p>uuid.uuid1-5<br><div class="highlight-box" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true" data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"># -*- coding: utf-8 -*-</span><br><span class="line"></span><br><span class="line">   import uuid</span><br><span class="line"></span><br><span class="line">   name = &quot;test_name&quot;</span><br><span class="line">   namespace = &quot;test_namespace&quot;</span><br><span class="line"></span><br><span class="line">   print uuid.uuid1()  # 带参的方法参见Python Doc</span><br><span class="line">   print uuid.uuid3(namespace, name)</span><br><span class="line">   print uuid.uuid4()</span><br><span class="line">   print uuid.uuid5(namespace, name)</span><br></pre></td></tr></table></figure></div></p>
<p>2不能用<br>一般用3或5即可</p>
<p>namespace ,name<br>namespace<br>uuid3 uuid5 这两个函数，第一个参数是一个 namespace 类型不是 str 而是一个 UUID</p>
<p>这里可以选择以下值中的一个，根据字符串的内容选择 NAMESPACE 下面是官方文档内容</p>
<pre><code>uuid.NAMESPACE_DNS

When this namespace is specified, the name string is a fully-qualified domain
name.

uuid.NAMESPACE_URL

When this namespace is specified, the name string is a URL.

uuid.NAMESPACE_OID

When this namespace is specified, the name string is an ISO OID.

uuid.NAMESPACE_X500

When this namespace is specified, the name string is an X.500 DN in DER or a
text output format.
</code></pre>
      
    </div>
    
  </div>
  
  
</article>

  
    <article id="post-python/python语法" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 itemprop="name">
      <a class="article-title" href="/huafeihua/2019/01/22/python/python语法/">Python-语法</a>
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/huafeihua/2019/01/22/python/python语法/" class="article-date">
  <time datetime="2019-01-22T09:58:59.000Z" itemprop="datePublished">2019-01-22</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/huafeihua/categories/python/">python</a>
  </div>

    
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/huafeihua/tags/python/">python</a></li></ul>

  </div>
  

  <div class="article-inner">
    
    <div class="article-content article-content-doorframe" itemprop="articleBody">
      
        

<!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>python语法</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">python语法</h1>
        <div class="show-content">
          <p>字符串</p><p>str='abcd'</p><p>数组</p><p>a=['abc','123','ddd']</p><p>元组</p><p>c=('nihai','wuxiao','lucy')</p><p>字典</p><p>d={1:'Jack',2:'lucy,name:'mingzi'}</p><p>集合</p><p>set([1,2,3])</p><p>    有序集合：frozenset([1,2,3,4])</p><p>    add update copy  clear pip  remove </p><p>discard ---num remove not do nothing---</p><p><br></p><hr><p><b>文件</b></p><p><b>open("filename", "*")</b></p><p><b>r w a w+ a+ </b></p><p><b>pythinic  -- with open("filename", "*" )  as f:</b></p><p><b>                        print(f.**)</b></p><p><b>大文件  fileinput</b></p><p><b>seek()  tell()</b></p><p><br></p><p><br></p><hr><p>d</p><p>循环（loop）   for i in list:</p><p>迭代（iterate）   a = iter(list)   a.next()   [line for line in ]</p><p>递归(recursion)</p><p>遍历（traversal）</p><hr><hr><p><b>面对对象</b></p><p>类：</p><p>属性</p><p>功能</p><p>实体具体对象</p><p><b>三大特性：</b></p><p>封装、继承、多态</p><p>1.定义类 Class 类名（）</p><p>class Student():</p><p>    def __init__(self,name,city)</p><p>        self.name = name</p><p>        self.city = city</p><p>2.初始化</p><p>def __init__(self,name,city)</p><p>self.name = name</p><p>self.city = city</p><p>def talk(self):</p><p>    print "I'm %s and come from %s." % (name,city)</p><p>3.实例</p><p>stu1 = Student('lilei','Beijing')</p><p>stu1.talk()</p><h2>引入包</h2><p>import time</p><p>time.strftime('%Y-%m-%d')</p><p>from time import strftime as strft</p><p>strft('%Y-%m-%d')</p><p>跨目录：</p><p>-School/student</p><p>from School.student import student</p><h2>异常处理</h2><p>FileNotFondError</p><p>try:</p><p>excetp FileNotFondError:</p><p>    print ------</p><blockquote>
<p>ser=11</p>
<p>try:</p>
<p>    print ser</p>
<p>except NameError:</p>
<p>    print "没定义变量"</p>
</blockquote><blockquote>
<p>ser=11</p>
<p>try:</p>
<p>    print ser</p>
<p>except BaseException as msg:</p>
<p>    print msg</p>
</blockquote><p>try....except....else</p><p>try....except....finaly</p><p>raise 抛出异常</p><blockquote>
<p>def divi(x,y):</p>
<p>    if y==0:</p>
<p>        raise ZeroDivisionError("0 is not allowed.")</p>
<p>    print x/y</p>
<p>try:</p>
<p>    divi(8,0)</p>
<p>except BaseException as msg:</p>
<p>    print msg</p>
</blockquote>
        </div>
      </div>
    </div>
  </body>
</html>

      
    </div>
    
  </div>
  
  
</article>

  


  <nav id="page-nav">
    
    <a class="extend prev" rel="prev" href="/huafeihua/">&laquo; 上一页</a><a class="page-number" href="/huafeihua/">1</a><span class="page-number current">2</span><a class="page-number" href="/huafeihua/page/3/">3</a><a class="page-number" href="/huafeihua/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/huafeihua/page/6/">6</a><a class="extend next" rel="next" href="/huafeihua/page/3/">下一页 &raquo;</a>
  </nav>


</section>
        <aside id="sidebar">
  
    <div class="widget-box">
  <div class="avatar-box">
    <img class="avatar" src="/huafeihua/images/default-avatar.jpeg" title="图片来自网络">
    <h3 class="avatar-name">
      
        听风看雨
      
    </h3>
    <p class="avatar-slogan">
      抗揍的愤青，半个IT男。
    </p>
  </div>
</div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/Linux/">Linux</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/python/">python</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/入坑/">入坑</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/技巧/">技巧</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/自动化/">自动化</a></li><li class="category-list-item"><a class="category-list-link" href="/huafeihua/categories/项目管理/">项目管理</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">标签</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Appium/">Appium</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Docker/">Docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Jenkins/">Jenkins</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Nginx/">Nginx</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Selenium/">Selenium</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/Ubuntu/">Ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/centos/">centos</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/flask/">flask</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/rabbit/">rabbit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/sql/">sql</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/ubuntu/">ubuntu</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/效率/">效率</a></li><li class="tag-list-item"><a class="tag-list-link" href="/huafeihua/tags/爬虫/">爬虫</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">标签云</h3>
    <div class="widget tagcloud">
      <a href="/huafeihua/tags/Appium/" style="font-size: 10px;">Appium</a> <a href="/huafeihua/tags/Docker/" style="font-size: 13.33px;">Docker</a> <a href="/huafeihua/tags/Jenkins/" style="font-size: 10px;">Jenkins</a> <a href="/huafeihua/tags/Nginx/" style="font-size: 10px;">Nginx</a> <a href="/huafeihua/tags/Selenium/" style="font-size: 13.33px;">Selenium</a> <a href="/huafeihua/tags/Ubuntu/" style="font-size: 10px;">Ubuntu</a> <a href="/huafeihua/tags/centos/" style="font-size: 16.67px;">centos</a> <a href="/huafeihua/tags/flask/" style="font-size: 20px;">flask</a> <a href="/huafeihua/tags/python/" style="font-size: 20px;">python</a> <a href="/huafeihua/tags/rabbit/" style="font-size: 10px;">rabbit</a> <a href="/huafeihua/tags/sql/" style="font-size: 10px;">sql</a> <a href="/huafeihua/tags/ubuntu/" style="font-size: 10px;">ubuntu</a> <a href="/huafeihua/tags/效率/" style="font-size: 10px;">效率</a> <a href="/huafeihua/tags/爬虫/" style="font-size: 10px;">爬虫</a>
    </div>
  </div>

  
    
  <div class="widget-box">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/huafeihua/archives/2019/01/">一月 2019</a></li></ul>
    </div>
  </div>

  
    
  <div class="widget-box">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/huafeihua/2019/01/29/python-mq/">python rabbitmq</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/python/Unittest/">Python-Unittest</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/项目管理/项目管理2018-07-23/">U项目管理</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/随笔/-Kanboard-安装之Windows/">Kanboard 安装之Windows</a>
          </li>
        
          <li>
            <a href="/huafeihua/2019/01/22/运维部署/单网卡实现内外网访问/">单网卡实现内外网访问</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
      </div>
      <footer id="footer">
  <div class="foot-box global-width">
    &copy; 2019 Edwin Ma &nbsp;&nbsp;
    驱动于 <a href="http://hexo.io/" target="_blank">Hexo</a><br>
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span id="busuanzi_container_site_pv">阁下是第<span id="busuanzi_value_site_pv"></span>个访客</span>
  </div>
</footer>
      <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

<script src="/js/jquery-2.0.3.min.js"></script>

  <link rel="stylesheet" href="/huafeihua/fancybox/jquery.fancybox.css">
  <script src="/huafeihua/fancybox/jquery.fancybox.pack.js"></script>


<script src="/huafeihua/js/script.js"></script>



    </div>
    <nav id="mobile-nav" class="mobile-nav-box">
  <div class="mobile-nav-img mobile-nav-top"></div>
  
    <a href="/huafeihua/" class="mobile-nav-link">首页</a>
  
    <a href="/huafeihua/categories" class="mobile-nav-link">分类</a>
  
    <a href="/huafeihua/archives" class="mobile-nav-link">归档</a>
  
    <a href="/huafeihua/tags" class="mobile-nav-link">标签</a>
  
    <a href="/huafeihua/about" class="mobile-nav-link">关于</a>
  
  <div class="mobile-nav-img  mobile-nav-bottom"></div>
</nav>    
  </div>
</body>
</html>